import { Controller, Get, Patch, UseGuards } from '@nestjs/common'
import { ArchiveData, ArchiveService } from './archive.service'
import { Responser } from '@app/decorators/responser.decorator'
import { AuthUserGuard } from '@app/guards/auth-user.guard'

@Controller('archive')
export class ArchiveController {
  constructor(private readonly archiveService: ArchiveService) { }

  @Get()
  @Responser.handle('Get archive')
  getArchive(): Promise<ArchiveData> {
    return this.archiveService.getCache()
  }

  @Patch()
  @UseGuards(AuthUserGuard)
  @Responser.handle('Update archive cache')
  updateArchive(): Promise<any> {
    return this.archiveService.updateCache()
  }
}
